$(document).ready(function(){
	initGoods();
	initOrderlist();
	getHb();
});


//获取商品列表


function showGoods(goodsList){
	var str=''
	for (var i=0;i<goodsList.length;i++) {
		str+='<a  onclick="aClick()"  target="_blank" href="detail.html?id='+goodsList[i].id+'">';
		str+='<li id="goods_'+goodsList[i].id+'">';
		str+='<div class="goods_list_img"><img src="../..'+goodsList[i].path+'" width="200" height="200" /></div>';
		str+='<div class="goods_list_info">'+goodsList[i].name+'<div style="padding:5px 0 0 0;">';
		str+='<span id="coin">'+goodsList[i].cost+'</span>H币</div></div></li></a>';
	}
	$("#goods_list").append(str);
}


function initGoods(){
	var url = "/HyperIT/goods/findGoods";
	$.get(url,function(data){
		if(data.serviceResult){
			var goodsList = data.resultParm.goodslist;
			showGoods(goodsList);
		}
		else{
			alert(data.resultInfo);
		}
	});
}

//获取兑换记录

function showOrderlist(orderList){
				for(var i=0;i<orderList.length;i++){
					$("#orderList").append('<li><span>'+orderList[i].name+'</span><span>'+orderList[i].createtime.split(" ")[0]+'</span></li>')
				}
			}
			
				
function initOrderlist(){
	var user= JSON.parse(getCookie("user"));
	var user_id = user.id;
	var path = user.head;
	var name = user.name;
	var url = "/HyperIT/goods/findPersonOrder";
	var parm = "userdetail_id="+user_id;
	$.get(url,parm,function(data){
		if(data.serviceResult){
			var orderList = data.resultParm.goodsorder;
			showOrderlist(orderList);
			$(".market_right_top img").attr("src",'../..'+thisUser.head);
			$("#name").html(name);
	}
		else{
			alert(data.resultInfo);
		}
	});
}
			
function getHb(){
	var user= JSON.parse(getCookie("user"));
	var user_id = user.id;
	var url = "/HyperIT/userdetail/getUserInfo";
	var parm = "userDetail_id="+user_id;
	$.post(url,parm,function(data){
		if(data.serviceResult){
			var hb = data.resultParm.userDetail.hb;
			$("#hb").html(hb);
		}
		else{
			alert(data.resultInfo);
		}
	});
}


